﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace _6.jkx
{

    public partial class gsjs : Form
    {
        public gsjs()
        {
            InitializeComponent();
            if (Directory.Exists(filePath))
            {
                DirectoryInfo TheFolder = new DirectoryInfo(filePath);
                //遍历文件夹
                //foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
                //    this.listBox1.Items.Add(NextFolder.Name);
                //遍历文件
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    this.LB_AllSatelliteName.Items.Add(NextFile.Name);
                }
            }
        }


       
        /// <summary>
        /// 卫星数据所在文件夹
        /// </summary>
        string filePath = Environment.CurrentDirectory + @"\text\\SatelliteData";
        void ShowSatelliteName()
        {
            
            if (Directory.Exists(filePath))
            {
                DirectoryInfo TheFolder = new DirectoryInfo(filePath);
                //遍历文件夹
                //foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
                //    this.listBox1.Items.Add(NextFolder.Name);
                //遍历文件
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    this.LB_AllSatelliteName.Items.Add(NextFile.Name);
                }
            }
            
            //FileStream FS = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
        
        }

        /// <summary>
        /// 计算卫星轨道数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_CaculateTwoLine_Click(object sender, EventArgs e)
        {
            if (LB_AllSatelliteName.SelectedItem.ToString() != "")
            {
                string fileName = LB_AllSatelliteName.SelectedItem.ToString();
              
            }
        }

      

        void SetLVData(int j)
        {
            LV_SatelliteData.Items.Clear();
            LV_SatelliteData.BeginUpdate();

            //for (int i = 0; i < sd.AllTimeRange.Count; i++)
            //{
            //    ListViewItem oneItem = new ListViewItem();
            //    oneItem.Text = sd.satelliteName;

            //    oneItem.SubItems.Add(sd.AllTimeRange[i].startDT.ToString("yyyy-MM-dd HH:mm:ss"));
            //    oneItem.SubItems.Add(sd.AllTimeRange[i].stopDT.ToString("yyyy-MM-dd HH:mm:ss"));

            //    double dangle = (sd.AllTimeRange[i].stopDT - sd.AllTimeRange[i].startDT).TotalMinutes;
            //    oneItem.SubItems.Add(dangle.ToString("F2") + "分钟");

            //    dangle = sd.AllTimeRange[i].InstantaneousSatelliteLocation.Min(M => M.nowAZ);
            //    oneItem.SubItems.Add(dangle.ToString("F2") + "°");

            //    dangle = sd.AllTimeRange[i].InstantaneousSatelliteLocation.Max(M => M.nowAZ);
            //    oneItem.SubItems.Add(dangle.ToString("F2") + "°");
            //    dangle = sd.AllTimeRange[i].InstantaneousSatelliteLocation.Min(M => M.nowEL);
            //    oneItem.SubItems.Add(dangle.ToString("F2") + "°");

            //    dangle = sd.AllTimeRange[i].InstantaneousSatelliteLocation.Max(M => M.nowEL);
            //    oneItem.SubItems.Add(dangle.ToString("F2") + "°");
                

            //    LV_SatelliteData.Items.Add(oneItem);

            //}
            LV_SatelliteData.EndUpdate();
        
        }

        private void LV_SatelliteData_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LV_SatelliteData.SelectedItems.Count > 0)
            {

                int index = LV_SatelliteData.SelectedItems[0].Index;
                MessageBox.Show("选中行号：" + index);
                //LV_AllTimeData.Clear();

                LV_AllTimeData.Items.Clear();
                LV_AllTimeData.BeginUpdate();
                
                //for (int i = 0; i < SD.AllTimeRange[index].InstantaneousSatelliteLocation.Count; i++)
                //{
                //    ListViewItem oneItem = new ListViewItem();
                //    oneItem.Text = (i + 1).ToString();

                //    oneItem.SubItems.Add(SD.AllTimeRange[index].InstantaneousSatelliteLocation[i].nowTime.ToString("yyyy-MM-dd HH:mm:ss"));
                //    oneItem.SubItems.Add(SD.AllTimeRange[index].InstantaneousSatelliteLocation[i].nowAZ.ToString("F4") + "°");
                //    oneItem.SubItems.Add(SD.AllTimeRange[index].InstantaneousSatelliteLocation[i].nowEL.ToString("F4") + "°");
                //    LV_AllTimeData.Items.Add(oneItem);
                //}
                LV_AllTimeData.EndUpdate();
            }
        }
    }
}
